package main

import (
	_ "fmt"
	_ "github.com/gin-gonic/gin"
	"github.com/spf13/viper"
	"local/config"
	"local/databases/mysql"
	"local/databases/redis"
	"local/routers"
	"local/servers"
	"local/utils"
	_ "net/http"
)

func main() {

	config.InitConfig()

	//初始化redis连接
	redis.InitRedis()

	//初始化mysql连接
	err := mysql.InitDB()
	if err != nil {
		panic(err)
	}
	defer mysql.Close()

	//初始化外部消息队列连接
	utils.InitMQ()

	//初始化聊天室模块
	servers.InitChat()

	//设置路由
	r := routers.SetupRouters()

	//加载端口号
	port := viper.GetString("server.port")
	_ = r.Run(":" + port)
}
